<template>
  <div>
      <div class="tpojia">
          <div class="poyutotot">
              <van-nav-bar title="修改地址" 
              @click-left="fanhui"
              @click-right="hhijia"
               left-arrow>
                  <!-- <template #right>
                    <van-icon name="search" size="18" />
                  </template> -->
              </van-nav-bar>
          </div>
          <div class="youm">
            <van-address-edit
              :show-postal="false"
              :show-area="false"
              :show-set-default="false"
              :address-info="AddressInfo"
              :search-result="searchResult"
              
              @save="onSave"
              @delete="onDelete"
              />
          </div>
      </div>
  </div>
</template>

<script>

import Vue from 'vue';
import { AddressEdit,Toast,Icon } from 'vant';
Vue.use(AddressEdit).use(Toast).use(Icon);
import { NavBar } from 'vant';
Vue.use(NavBar);
import { Area } from 'vant';
// import { areaList } from '@vant/area-data';:area-columns-placeholder="['请选择', '请选择', '请选择']"
Vue.use(Area);
export default {
    data(){
        return{
          areaList:"",
          searchResult: [
              
          ],
          id:10,
          AddressInfo:{
            name:"13",
            id:2,
            addressDetail:"14",
            tel:"17612345678",
          },
          Index:null,
        }
    },
    methods: {
        onSave(content){
        // Toast('save');
            console.log(content);
            let data = {
            id:content.id,
            name:content.name,
            tel:content.tel,
            address:content.addressDetail,
            }
        let lisgos = JSON.parse(sessionStorage.getItem('addresslist'));//取数据
          lisgos[this.Index]=data;
          window.sessionStorage.setItem('addresslist',JSON.stringify(lisgos));//存数据
        //    this.$router.push({name:'adderss',params:{obj:data,index:this.Index}})
            this.$router.push('/adderss');
            console.log(data)
            
        },
        onDelete() {
        Toast('delete');
        },
        onChangeDetail(val) {
        if (val) {
            this.searchResult = [
            {
                name: '黄龙万科中心',
                address: '杭州市西湖区',
            },
            ];
        } else {
            this.searchResult = [];
        }
        },
        fanhui(){
            this.$router.push('/adderss');
        },
        hhijia(){
            this.$router.push('/adderss');
        },
        getsgju(){
            this.AddressInfo=this.$route.params.obj;
            this.Index=this.$route.params.index;
        },
    },
    created(){
    //   console.log(this.$route.params.obj);
       this.getsgju()
    }
}
</script>

<style lang="less">
.tpojia{
    width: 100%;
    height: 100%;
    position: fixed;
    background-color: #fff;
    z-index: 90;
    .poyutotot{
      width: 100%;
      height: 50px;
      .van-nav-bar__content{
        i{
          color: #000;
        }
      }
    }
    .youm{
        width: 100%;
        margin-top: 10px;
    }
}
</style>